package com.clock.shop.service.impl;

import com.clock.shop.domain.ShopShop;
import com.clock.shop.repository.CommentRepository;
import com.clock.shop.service.IUserScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class UserScoreServiceImpl implements IUserScoreService {
    @Autowired
    private CommentRepository commentRepository;
    public float getShopScore(Long shopId) {
        return commentRepository.findAverageCommentRateByShopId(shopId);
    }

    public List<Long> getTopShop() {
        List<Long> sortedShopIds = commentRepository.findTopShopIdsByAverageRating();
        List<Long> topShopIds = sortedShopIds.stream().limit(3).collect(Collectors.toList());
        return topShopIds;
    }

}
